﻿namespace Chain.BLL
{
    using Chain.IDAL;
    using Chain.Model;
    using System;
    using System.Collections.Generic;
    using System.Data;

    public class WeiXinLog
    {
        private readonly Chain.IDAL.WeiXinLog dal = new Chain.IDAL.WeiXinLog();

        public int Add(Chain.Model.WeiXinLog model)
        {
            return this.dal.Add(model);
        }

        public List<Chain.Model.WeiXinLog> DataTableToList(DataTable dt)
        {
            List<Chain.Model.WeiXinLog> list = new List<Chain.Model.WeiXinLog>();
            int count = dt.Rows.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Chain.Model.WeiXinLog item = new Chain.Model.WeiXinLog();
                    if ((dt.Rows[i]["WeiXinLogID"] != null) && (dt.Rows[i]["WeiXinLogID"].ToString() != ""))
                    {
                        item.WeiXinLogID = int.Parse(dt.Rows[i]["WeiXinLogID"].ToString());
                    }
                    if ((dt.Rows[i]["MemWeiXinCard"] != null) && (dt.Rows[i]["MemWeiXinCard"].ToString() != ""))
                    {
                        item.MemWeiXinCard = dt.Rows[i]["MemWeiXinCard"].ToString();
                    }
                    if ((dt.Rows[i]["RecordContent"] != null) && (dt.Rows[i]["RecordContent"].ToString() != ""))
                    {
                        item.RecordContent = dt.Rows[i]["RecordContent"].ToString();
                    }
                    if ((dt.Rows[i]["RecordContentType"] != null) && (dt.Rows[i]["RecordContentType"].ToString() != ""))
                    {
                        item.RecordContentType = int.Parse(dt.Rows[i]["RecordContentType"].ToString());
                    }
                    if ((dt.Rows[i]["StatusCode"] != null) && (dt.Rows[i]["StatusCode"].ToString() != ""))
                    {
                        item.StatusCode = dt.Rows[i]["StatusCode"].ToString();
                    }
                    if ((dt.Rows[i]["RandomCode"] != null) && (dt.Rows[i]["RandomCode"].ToString() != ""))
                    {
                        item.RandomCode = dt.Rows[i]["RandomCode"].ToString();
                    }
                    if ((dt.Rows[i]["ErrorTimes"] != null) && (dt.Rows[i]["ErrorTimes"].ToString() != ""))
                    {
                        item.ErrorTimes = int.Parse(dt.Rows[i]["ErrorTimes"].ToString());
                    }
                    if ((dt.Rows[i]["WeiXinLogCreateTime"] != null) && (dt.Rows[i]["WeiXinLogCreateTime"].ToString() != ""))
                    {
                        item.WeiXinLogCreateTime = DateTime.Parse(dt.Rows[i]["WeiXinLogCreateTime"].ToString());
                    }
                    list.Add(item);
                }
            }
            return list;
        }

        public bool Delete(int WeiXinLogID)
        {
            return this.dal.Delete(WeiXinLogID);
        }

        public bool Delete(string MemWeiXinCard)
        {
            return this.dal.Delete(MemWeiXinCard);
        }

        public bool DeleteList(string WeiXinLogIDlist)
        {
            return this.dal.DeleteList(WeiXinLogIDlist);
        }

        public bool Exists(int WeiXinLogID)
        {
            return this.dal.Exists(WeiXinLogID);
        }

        public DataSet GetAllList()
        {
            return this.GetList("");
        }

        public DataSet GetList(string strWhere)
        {
            return this.dal.GetList(strWhere);
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.dal.GetList(Top, strWhere, filedOrder);
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }

        public Chain.Model.WeiXinLog GetModel(int WeiXinLogID)
        {
            return this.dal.GetModel(WeiXinLogID);
        }

        public Chain.Model.WeiXinLog GetModel(string MemWeiXinCard)
        {
            return this.dal.GetModel(MemWeiXinCard);
        }

        public List<Chain.Model.WeiXinLog> GetModelList(string strWhere)
        {
            DataSet list = this.dal.GetList(strWhere);
            return this.DataTableToList(list.Tables[0]);
        }

        public int GetRecordCount(string strWhere)
        {
            return this.dal.GetRecordCount(strWhere);
        }

        public bool Update(Chain.Model.WeiXinLog model)
        {
            return this.dal.Update(model);
        }
    }
}

